import mongoose from 'mongoose'
import utils from '../utils'
const Schema = mongoose.Schema

const SMSSchema = new Schema({
  phone: String,
  code: String,
  status: {
    type: Number,
    default: -1 // -1未使用 1已使用
  },
  createTime: {
    type: String,
    default: utils.currentTimeStamp()
  }
})

SMSSchema.set('collection', 'SMS')

// hidden some field
SMSSchema.options.toJSON = {
  virtuals: true,
  versionKey: false,
  transform (doc, ret) {
    ret.id = ret._id
    delete ret._id
  }
}
mongoose.model('SMS', SMSSchema)
